import java.util.Hashtable;


public class Metadata {
	
	private Object data;
	private int type;
	private static String[] typeArray = { "byte", "short", "int", "float", "string", "short:byte:short", "int[]" };
	
	public Metadata(Object data, int type) {
		super();
		this.data = data;
		this.type = type;
	}

	
	public Object getData() {
		return data;
	}
	public void setData(Object data) {
		this.data = data;
	}
	public int getType() {
		return type;
	}
	public void setType(int type) {
		this.type = type;
	}
	
	public String toString()
	{
		switch (type)
		{
		case 0:
			return "[" + typeArray[type] + "|" + String.format("%x", (byte) data) + "]";
		case 1:
			return "[" + typeArray[type] + "|" + String.format("%x", (short) data) + "]";
		case 2:
			return "[" + typeArray[type] + "|" + String.format("%x", (int) data) + "]";
		case 3:
			return "[" + typeArray[type] + "|" + String.format("%x", (float) data) + "]";
		case 4:
			return "[" + typeArray[type] + "|" + (String) data + "]";
		case 5:
			Hashtable<String, Object> table = (Hashtable<String, Object>) this.data;
			return "[id:" + (short) table.get("id") + 
					"|count:" + String.format("%x", (byte) table.get("count")) + 
					"|damage:" + (short) table.get("damage") +"]";
		case 6:
			int[] array = (int[]) this.data;
			return "[" + (int) array[0] + 
					"|" + (int) array[1] + 
					"|:" + (int) array[2] +"]";
		default:
			return "error";
		}
	}
}
